package gruppe7.tlrs;

import java.util.HashMap;

public class TLRSControl {
	
	private static final String VERSION = "2.0";
	
	private StationList stationList;
	private static TLRSControl trlsControl = null;
	
	public static TLRSControl getInstance()
	{
		if (trlsControl == null) trlsControl = new TLRSControl();
		return trlsControl;
	}
	
	private TLRSControl(){
		stationList = new StationList();
		setStations();
	}
	
	public Integer getZone(String stationName){
		return stationList.getStation(stationName).getZone();
	}
	public String getStationDetails(String stationName){
		return stationList.getStation(stationName).toString();
	}
	
	public String getVersion() {
		return VERSION;
	}
	
	//this class is used to establish test data until database part is finished
	public void setStations() {
		
		stationList.createStation("Huntersborough",40);
		stationList.createStation("Heatherville",42);
		stationList.createStation("Birdford",45);
		stationList.createStation("Wide",47);
		stationList.createStation("Dizzyholme",40);
		stationList.createStation("Ravenholme",40);
		stationList.createStation("Nearabout",40);
	}
	
	public HashMap<String, Station> getStations()
	{
		return stationList.getStations();
	}
	
	public boolean updateStation(String oldName, String stationName, Integer zone, String manager, String date, String comment)
	{
		boolean update = false;
		if(getInstance().stationList.updateStation(oldName, stationName, zone, manager, date, comment))
		{
			update = true;
		}
		
		return update;
	}
}
